package com.sname.demofeign.controller;

import com.sname.demofeign.entity.User;
import com.sname.demofeign.service.FeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created By  醉美柳舞之众星捧月
 *
 * @author 宋贤坤
 * @date 2018/11/19 17:41
 */
@RestController
public class Controller {

    @Autowired
    private FeignService feignService;
    // feignService能够被注入进来,是因为在FeignService上面有那个什么注解
    // 也是可以被注入进来的,并不是只有@service注解才能够被注入进来;
    // (@FeignClient注解与@service注解功能一致,只是前者注解可以加入名称)

    // 调用远程的hello
    @RequestMapping("/consumer")
    public String helloConsumer() {
        return feignService.hello();
    }

    @RequestMapping("/consumer2")
    public String helloConsumer2() {
        String r1 = feignService.hello("userName");
        String r2 = feignService.hello("userName", 28).toString();
        String r3 = feignService.hello(new User("userName", "pwd"));
        return r1 + "---" + r2 + "---" + r3;
    }
}